class BootstrapForm(object):
    def __init__(self, *args, **kwargs):
        """重写init给所有字段动态添加属性"""
        super(BootstrapForm, self).__init__(*args, **kwargs)
        for name, field in self.fields.items():  # name对应的就是每个字段的名字,field对应的是对象
            field.widget.attrs['class'] = 'form-control'  # 添加class属性
            field.widget.attrs['placeholder'] = '请输入%s' % field.label  # 添加placeholder属性field.label拿到介绍